<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2021/12/28
  Time: 23:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri ="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>闲优购</title>
  <link rel="icon" href="img/weblogo.png" >
  <link rel="stylesheet" type="text/css" href="bootstrap-5.1.3-dist/css/bootstrap.min.css"/>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
  <link rel="stylesheet" type="text/css" href="css/ycc.css"/>
  <script type="text/javascript" src="js/jquery-3.6.0-min.js"></script>
  <script type="text/javascript" src="bootstrap-5.1.3-dist/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="js/card_user_buy_record.js"></script>
</head>
<body>

<h5>当前位置:用户管理>>修改用户密码</h5>
<h5 class="text-center">选择修改密码的用户</h5>
<form id="myForm" action="/adminUpdateUser">
    <select class="form-select form-select-lg mb-3" aria-label=".form-select-lg example" name="select_name">
      <c:forEach items="${sessionScope.userList}" var="user">
        <option value="${user.id}">${user.name}</option>
      </c:forEach>
    </select>

    <div class="form-floating mb-3">
      <input type="password" class="form-control" id="floatingInput" placeholder="请输入新的密码" name="pw">
      <label for="floatingInput">新的密码</label>
    </div>

    <button id="bt-ok" type="button" class="btn btn-outline-success w-100">确认修改</button>
</form>
</body>
<script>
    $("#bt-ok").click(function (){
        var data = $("#myForm").serialize();
        $.ajax({
            url: '/adminUpdateUser',
            async: false,
            data:data,
            error: function (){
                alert('AJAX请求失败')
            },
            success: function (data){
                if(data == "true")
                    alert('更改成功!')
                else
                    alert('更改失败!')
                window.location.href="card_admin_update_user.jsp"
            }
        });
    });
</script>
</html>
